<?php

require 'include/global.php';
require './include/validate.php';
require './include/all_left.php';
include("FCKeditor/fckeditor.php");

require_once 'include/advisory_db.php';

//security 
if ($_SESSION['status'] != "Premium") {
    echo "<meta http-equiv=\"refresh\" content=\"0;URL=errorall.php?errid=rc_1006\">";
    exit;
}

if ($_POST[action] == '' && $_GET[action] != 'edit') {
    $rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE `re_id`='" . $_GET[id] . "' AND `re_uid`= '" . $_SESSION[uid] . "'");
    if (empty($rs) || $rs[re_aliasname] != '') {
        echo "DATABASE ERROR";
        exit;
    }
}
if ($_GET[action] == 'delete') {
    $sql = "DELETE FROM " . $db_prefix . "resume WHERE `re_id`=" . $_GET[id];
    $DB->query($sql);
}

$smarty->display('header.tpl');
include ("./check/checkpostresumealias.php");
if ($statusForEdit != 1) {
    if ($_SESSION[usertype] == "recruiter" && $_GET[id] != '') {
        $rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE re_usertype='" . $_SESSION[usertype] . "' AND re_uid ='" . $_SESSION[uid] . "' AND re_id='" . $_GET[id] . "'");
    }
    $re_fname = $rs[re_fname];
    $re_lname = $rs[re_lname];
    $re_aliasname = $rs[re_aliasname];
    $re_email = $rs[re_email];
    $re_address1 = $rs[re_address1];
    $re_address2 = $rs[re_address2];
    $re_lostate = $rs[re_lostate];
    $re_locountry = $rs[re_locountry];
    $re_locity = $rs[re_locity];
    $re_phone1 = $rs[re_phone1];
    $re_phone2 = $rs[re_phone2];
    $re_jobtype = $rs[re_jobtype];
    $re_jobindustry = $rs[re_jobindustry];
    $re_jobtitle = $rs[re_jobtitle];
    $re_yearexp = $rs[re_yearexp];
    $re_edulevel = $rs[re_edulevel];
    $re_proflicense = $rs[re_proflicense];
    $re_mgmt = $rs[re_mgmt];
    $re_profit = $rs[re_profit];
    $re_spoken = $rs[re_spoken];
    $re_prolang = $rs[re_prolang];
    $re_ip = $rs[re_ip];
    $re_ussecurity = $rs[re_ussecurity];
    $re_authorize = $rs[re_authorize];
    $re_detail = $rs[re_detail];
    $re_comments = $rs[re_comments];
    $re_regtime = $rs[re_regtime];
    $re_upload = $rs[re_upload];
    $re_jobsearchstatus = $rs[re_jobsearchstatus];
    $re_describeme = $rs[re_describeme];
    $re_favoriatebook = $rs[re_favoriatebook];
    $re_highachieve = $rs[re_highachieve];
    $re_iplan = $rs[re_iplan];
    $re_iliketo = $rs[re_iliketo];
    $re_comments = $rs[re_comments];
    $re_prvemployer = $rs[re_prvemployer];
    $re_prvempstatus = $rs[re_prvempstatus];
    $re_professavilable = $rs[re_professavilable];
    $re_currentpay = $rs[re_currentpay];
    $re_desiredpay = $rs[re_desiredpay];
    $re_benefits = $rs[re_benefits];
    $re_schoolattend = $rs[re_schoolattend];
    $re_personalweb = $rs[re_personalweb];
    $re_private = $rs[re_private];
    $re_updtime = $rs[re_updtime];
    $re_sponsorship = $rs[re_sponsorship];
}

if ($re_regtime == '') {
    $re_regtime = time();
}
if ($rs['re_id'] > 0) {
    $fid = $rs['re_id'];
} else {
    $fid = ($_GET['id'])?$_GET['id']:$_POST['fid'];
}


//alias id/detail
if ($_GET[action] == 'edit' && $_POST[action] == '') {
    $actiontype = "resume_doupdate";
    $aliasNum = $re_aliasname;
} elseif ($_POST[action] == '') {
    $actiontype = "resume_doinsert";
    $aliaslist = $DB->fetch_one_array("SELECT re_aliasid,re_aliasname FROM " . $db_prefix . "resume WHERE `re_fid` = $_GET[id] ORDER BY `re_id` DESC");
    if (empty($aliaslist)) {
        $aliasid = "1";
        $aliasNum = "1";
    } else {
        $aliasid = $aliaslist[re_aliasid] + 1;
        $aliasNum = $aliaslist[re_aliasid] + 1;
    }
    //if( $aliaslist[re_aliasname]!='' ){ $aliasNum = $aliaslist[re_aliasname]; }
}

ob_clean();
ob_start();

/*
  echo '
  <script type="text/javascript" src="include/textarealimited/Bs_Misc.lib.js"></script>
  <script type="text/javascript" src="include/textarealimited/Bs_LimitedTextarea.class.js"></script>
  <script type="text/javascript" src="include/textarealimited/Bs_ColorUtil.lib.js"></script>
  <script>
  function init() {
  myLimitedFoo = new Bs_LimitedTextarea(\'re_detail\', 5000);
  myLimitedFoo.setBgColorWarning();
  myLimitedFoo.draw();
  }

  </script>';
 */
if ($re_locountry == '') {
    $re_locountry = 211;
}


$cpforms->formheader(array('title' => 'Candidate Record', 'name' => 'article', 'enctype' => 'multipart/form-data'));
$cpforms->makehidden(array('name' => 'action', 'value' => $actiontype));
$cpforms->makehidden(array('name' => 'fid', 'value' => $fid));
$cpforms->makehidden(array('name' => 'aliasid', 'value' => $aliasid));
$cpforms->gethightext(array('text' => "Create Date", 'value' => date("m/d/Y", $re_regtime), 'view' => 1));
if ($re_updtime == 0) {
    $re_updtime = $re_regtime;
}
$cpforms->gethightext(array('text' => "Last Updated", 'value' => date("m/d/Y", $re_updtime), 'view' => "1"));
$cpforms->makeselect(array('one' => 1, 'text' => "Job Search Status", 'name' => "re_jobsearchstatus", 'option' => $jobSearchStatus, 'only' => 1, 'selected' => "$re_jobsearchstatus", 'view' => "$view", 'icon' => "'Indicate  job search status.  You may edit this later.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text' => "Alias Name", 'name' => "re_aliasname", 'only' => 1, 'value' => "$aliasNum", 'view' => "$view", 'icon' => "'To rename an alias record simply type over the default alias number.  Alias names must be 6 characters or less.  Any combination of numbers and letters are acceptable.', WIDTH, 200, SHADOW, true", 'size' => 6, 'max' => 6));


$cpforms->longline(array('title' => "Contact Information"));
$cpforms->gethightext(array('text' => "First Name", 'name' => "re_fname", 'only' => 1, 'value' => "$re_fname", 'view' => "$view", 'read' => 1, 'icon' => "' This field may not be changed on alias records.  You may change it from the original candidate record. ', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text' => "Last Name", 'name' => "re_lname", 'only' => 1, 'value' => "$re_lname", 'view' => "$view", 'read' => 1, 'icon' => "' This field may not be changed on alias records.  You may change it from the original candidate record. ', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text' => "Contact Email", 'name' => "re_email", 'only' => 1, 'value' => "$re_email", 'view' => "$view"));
$cpforms->gethightext(array('text' => "Street Address 1", 'name' => "re_address1", 'only' => 1, 'value' => "$re_address1", 'view' => "$view"));
$cpforms->gethightext(array('text' => "Street Address 2", 'name' => "re_address2", 'value' => "$re_address2", 'view' => "$view"));
$cpforms->gethightext(array('text' => "Location - City", 'only' => 1, 'name' => "re_locity", 'value' => "$re_locity", 'view' => "$view"));
$cpforms->makeselect(array('one' => 1, 'text' => "Location - State", 'name' => "re_lostate", 'only' => 1, 'option' => $state, 'selected' => "$re_lostate", 'view' => "$view", 'viewfunction' => 'state'));
$cpforms->makeselect(array('one' => 1, 'text' => "Location - Country", 'name' => "re_locountry", 'only' => 1, 'option' => $country, 'selected' => "$re_locountry", 'view' => "$view", 'viewfunction' => 'country'));
$cpforms->gethightext(array('text' => "Primary Phone", 'name' => "re_phone1", 'only' => 1, 'value' => "$re_phone1", 'view' => "$view"));
$cpforms->maketextarea(array('text' => "Recruiter Contact", 'name' => "re_phone2", 'value' => "$re_phone2", 'view' => "$view", 'icon' => "'Include recruiter contact information here.  Leave blank if not applicable.', WIDTH, 200, SHADOW, true"));

$cpforms->longline(array('title' => "Desired Job Detail"));
$cpforms->makeselect(array('one' => 1, 'text' => "Desired Job Type", 'name' => "re_jobtype", 'option' => $jobtype, 'only' => 1, 'selected' => "$re_jobtype", 'view' => "$view"));
$cpforms->makeselect(array('one' => 1, 'text' => "Desired Job Category/Industry", 'name' => "re_jobindustry", 'option' => $jobcategory, 'only' => 1, 'selected' => "$re_jobindustry", 'view' => "$view"));
$cpforms->gethightext(array('text' => "Desired Job Title", 'name' => "re_jobtitle", 'only' => 1, 'value' => "$re_jobtitle", 'view' => "$view"));
$cpforms->gethightext(array('text' => "Current Base Pay", 'name' => "re_currentpay", 'value' => "$re_currentpay", 'view' => "$view", 'icon' => "'Indicate current annual base salary', WIDTH, 200, SHADOW, true", "prev" => "$", "next" => "(No Commas)", "size" => "10"));
$cpforms->gethightext(array('text' => "Desired Base Pay", 'name' => "re_desiredpay", 'value' => "$re_desiredpay", 'view' => "$view", 'icon' => "'Indicate desired annual base salary', WIDTH, 200, SHADOW, true", "prev" => "$", "next" => "(No Commas)", "size" => "10"));
$cpforms->maketextarea(array('text' => "Other Compensation/Benefits", 'name' => "re_benefits", 'value' => stripslashes($re_benefits), 'view' => "$view", 'icon' => "'Indicate other preferred compensation or benefits such as sign-on bonus or stock grants.  ', WIDTH, 200, SHADOW, true"));
$cpforms->longline(array('title' => "Qualifications"));
$cpforms->maketextarea(array('text' => "Schools Attended", 'name' => "re_schoolattend", 'value' => stripslashes($re_schoolattend), 'view' => "$view"));

$cpforms->makeselect(array('one' => 1, 'text' => "Years of Work Experience", 'name' => "re_yearexp", 'only' => 1, 'option' => $yearexp2, 'selected' => "$re_yearexp", 'view' => "$view", 'viewfunction' => 'yearexp'));
$cpforms->makeselect(array('one' => 1, 'text' => "Highest Education Level", 'name' => "re_edulevel", 'only' => 1, 'option' => $education, 'selected' => "$re_edulevel", 'view' => "$view", 'viewfunction' => 'education', 'icon' => "' Indicate the highest level of education achieved here.', WIDTH, 200, SHADOW, true"));
$cpforms->gethightext(array('text' => "Professional Licenses/Certification", 'name' => "re_proflicense", 'value' => "$re_proflicense", 'view' => "$view", 'icon' => "'List all professional licenses or certifications obtained here.', WIDTH, 200, SHADOW, true"));
$cpforms->makeselect(array('one' => 1, 'text' => "Years of People Mgmt Experience", 'name' => "re_mgmt", 'only' => 1, 'option' => $yearexp2, 'selected' => "$re_mgmt", 'view' => "$view", 'viewfunction' => 'yearexp'));
$cpforms->makeselect(array('one' => 1, 'text' => "Years of Profit & Loss Responsibility", 'name' => "re_profit", 'only' => 1, 'option' => $yearexp2, 'selected' => "$re_profit", 'view' => "$view", 'viewfunction' => 'yearexp'));
$cpforms->gethightext(array('text' => "Spoken Language(s)", 'name' => "re_spoken", 'only' => 1, 'value' => "$re_spoken", 'view' => "$view"));
$cpforms->gethightext(array('text' => "Programming Language Knowledge", 'name' => "re_prolang", 'value' => "$re_prolang", 'view' => "$view"));
$cpforms->gethighradio(array('text' => "High-Tech Patent/IP owner or Co-owner?", 'name' => "re_ip", 'only' => 1, 'selected' => "$re_ip", 'view' => "$view"));
$cpforms->gethighradio(array('text' => "U.S.Government Security Clearance?", 'name' => "re_ussecurity", 'only' => 1, 'selected' => "$re_ussecurity", 'view' => "$view"));
$cpforms->maketextarea(array('text' => "Authorized to work in the following country", 'name' => "re_authorize", 'only' => 1, 'value' => "$re_authorize", 'view' => "$view", 'icon' => "' Indicate in which country the candidate is authorized to work.', WIDTH, 200, SHADOW, true"));
$cpforms->makefck(array('text' => "Resume Detail", 'name' => "re_detail", 'id' => "re_detail", 'only' => 1, 'value' => stripslashes($re_detail), 'view' => "$view", 'icon' => "' Please include details of all relevant work experience, education and training here.  You can type-in your content or cut and paste them.  Please DO NOT include your name or contact information here. You may edit this later. Be sure to press the \'Shift\' and \'Enter\' keys to create single space lines.', WIDTH, 200, SHADOW, true"));
$cpforms->makefile(array('text' => "Picture (Only accept image size less than 50KB.)", 'name' => "uploadfile", 'value' => "$re_upload", 'url' => "uploadfiles/resumes/", 'view' => "$view"));


if ($_SESSION[usertype] == "recruiter") {
    $cpforms->longline(array('title' => "Work Status, Employment and Professional References"));
    $cpforms->maketextarea(array('text' => "Three Previous Employers", 'name' => "re_prvemployer", 'only' => 1, 'value' => "$re_prvemployer", 'view' => "$view", 'icon' => "'Please list 3 previous employers.', WIDTH, 200, SHADOW, true"));
    $cpforms->gethighradio(array('text' => "Previous Employment Status Checked?", 'name' => "re_prvempstatus", 'only' => 1, 'selected' => "$re_prvempstatus", 'view' => "$view", 'icon' => "'You are not required to perform employment status checking prior to submitting the applicant.  But it may improve your applicant\'s chances of being considered before other applicants.  Be ready to provide the necessary information if requested by the employer.', WIDTH, 200, SHADOW, true"));
    $cpforms->gethighradio(array('text' => "Three Professional References Available?", 'name' => "re_professavilable", 'only' => 1, 'selected' => "$re_professavilable", 'view' => "$view", 'icon' => "'Does the applicant have a minimum of 3 references available to speak of his/her past work performance?  This is not required but may improve your applicant\'s chances of being considered before others.  Be ready to provide the necessary information if asked by the employer.', WIDTH, 200, SHADOW, true"));
    //$cpforms->gethighradio(array ('text' => "Will the applicant require work sponsorship for this job?",'name' => "re_sponsorship",'only' => 1,'selected' => "$re_sponsorship",'view' => "$view"));
    $cpforms->longline(array('title' => "Privacy Status"));
    $cpforms->gethighradio(array('text' => "Status", 'name' => "re_private", 'options' => $pri_pub, 'only' => 1, 'selected' => "$re_private", 'view' => "$view", 'icon' => "'By default all record(s) are hidden or is \'Private\' and viewable only by you.  If you wish to unhide your record or make it searchable by recruiters, then select the \'Public\' option. You may change this selection any time.', WIDTH, 200, SHADOW, true"));
    $cpforms->makePhpCaptcha(array('text' => "Safe Code", 'name' => "imagecode", 'value' => "$_POST[imagecode]", 'only' => 1));
}
if ($_GET[action] == 'edit' || !empty($rs)) {
    $cpforms->formfooter(array(
        'confirm' => 3
    ));
} else {
    $cpforms->formfooter(array(
        'confirm' => 1
    ));
}

$reg_data = ob_get_contents();
ob_end_clean();

if ($err != '') {
    $smarty->assign("err", $err);
}
$smarty->assign("reg", $reg_data);

$title = "Candidate Alias Record - $re_fname $re_lname ($aliasNum)";

$smarty->assign('title', $title);
$smarty->assign('content', $content);
$smarty->display('allleft.tpl');
$smarty->display('reg.tpl');


$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
